﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RFIDStockManagement.Model.InterFace;
using RFIDStockManagement.BLL;

namespace RFIDStockManagement.Client.Report
{
    public class StockCheckReportPlugIn : ReportPlugIn
    {
        IReport totalReport;
        IReport detailReport;

        public StockCheckReportPlugIn()
        {
            Filter = new StockCheckFilter();
            this.OnBarClick += new ReportBarEvent(OnBarClicked);
            AddBar("barMore", "盘盈报表", "", true);
            AddBar("barLess", "盘亏报表", "", true);
            AddBar("barTotal", "盘点报告", "", true);
        }

        private void OnBarClicked(object sender, string barName, ref bool isCanceled)
        {
            switch (barName)
            {
                case "barmore":
                    if (detailReport == null)
                    {
                        detailReport = ReoportCreator.CreateDBReporter("detail_stock_check");
                    }
                    Filter.Filters["reportType"] = 0;
                    Owner.ThisReport = detailReport;
                    Owner.ThisReport.Filters = Filter.Filters;
                    break;
                case "barless":
                    if (detailReport == null)
                    {
                        detailReport = ReoportCreator.CreateDBReporter("detail_stock_check");
                    }
                    Filter.Filters["reportType"] = 1;
                    Owner.ThisReport = detailReport;
                    Owner.ThisReport.Filters = Filter.Filters;
                    break;
                case "bartotal":
                    if (totalReport == null)
                    {
                        totalReport = ReoportCreator.CreateDBReporter("total_stock_check");
                    }
                    Owner.ThisReport = totalReport;
                    Owner.ThisReport.Filters = Filter.Filters;
                    break;
            }

            Owner.RefreshColumns();

            RefreshReportData();

        }


    }
}
